package com.neusoft.controller;

import com.alibaba.fastjson.JSON;
import com.neusoft.bean.Perform;
import com.neusoft.entity.TagsEntity;
import com.neusoft.mapper.TagMapper;
import com.neusoft.response.ApiResponse;
import com.neusoft.utils.SqlSessionFactoryUtils;
import com.neusoft.utils.UserUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.PrintWriter;
import java.util.List;

@RestController
public class TagController {
    @Autowired
    SAXReader saxReader;
    @Autowired
    Perform tmp;
    @Autowired
    TagMapper tagMapper;
    @GetMapping("/tags")
    public ApiResponse<List<TagsEntity>> getTags() throws DocumentException {
//        int k = 32/0;
        int[] arr = {1,2};
        arr[2]++;

        //        tmp.perform();
//        Document document = saxReader.read(this.getClass().getClassLoader().getResource("emp.xml"));
//        Element rootElement = document.getRootElement();
//        String name = rootElement.element("name").getText();
//        String age = rootElement.element("age").getText();

        List<TagsEntity> allTags = tagMapper.getAllTags();
        return ApiResponse.success(allTags);
    }
}
